<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@page import="java.util.*"%>
<%@page import="support.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Choose Universities Page</title>
</head>
<body>
	<%
	//get the stateid of chosen
		String stateName = request.getParameter("stateName");
	%>
	<%
		support s = new support();
		
		//getUniversities returns a vector of vectors where each vector is a tuple of <string, vector>
		//with the string being the name of the country/state and the vector being the list of universities there
		Vector universities = s.getUniversities(stateName);
		//get vector of universities of chosen state
		session.setAttribute("location", stateName);
	%>
	<p>
		Your location:
		<%=stateName%>
	<form method="get" action="degreeDiscipline.jsp">
		<table border="1">
			<%
			//display all the universities of chosen state
			//in 3 columns
				for (int i = 0; i < universities.size() / 3; i++) {
					String univ = (String)universities.get(i * 3);
			%>
			<tr>
				<td><a href="degreeDiscipline.jsp?university=<%=univ%>">
						<%
							out.println("<br>" + univ + "<br>");
						%>
				</a></td>
				<%
						String univ2 = (String)universities.get(i*3 +1);%>
				<td><a
					href="degreeDiscipline.jsp?university=<%=univ2%>"> 
					<%
					 	out.println("<br>" + univ2 + "<br>");
					 %></a></td>
					 <%
						String univ3 = (String)universities.get(i*3 +2);%>
				<td><a
					href="degreeDiscipline.jsp?university=<%=univ3%>"> <%
 	out.println("<br>" +univ3 + "<br>");
 	}
 %>
				</a></td>
			</tr>
			<%
				//print the last row of states
				if (universities.size() % 3 != 0) {
					for (int i = 0; i < universities.size() % 3; i++) {
						String univ4 = (String)universities.get(universities.size() - 1 - i);
			%>
			<tr>
				<td><a
					href="degreeDiscipline.jsp?university= <%=univ4%>">
						<%
							out.println(univ4);
						%>
				</a></td>
			</tr>
			<%
				}
				}
			%>
		</table>
		<p>
			Cannot find your university? <br> <p>Type your university name
			here: <input type="text" size="30" name="university"> <input
				type="submit" size="10" value="submit">
	</form>
</body>
</html>